﻿using System.Drawing;

namespace GDI
{
    public class PlotPoint : PrintableItem
    {
        /* ------------------------------------------------------------------------------------------ */

        private float f_R;

        private Pen f_Pen;
        private Brush f_Brush;

        /* ------------------------------------------------------------------------------------------ */

        public float R { get { return f_R; } set { f_R = value; OnPropertyChanged(); } }
        public Pen Pen { get { return f_Pen; } set { f_Pen = value; OnPropertyChanged(); } }
        public Brush Brush { get { return f_Brush; } set { f_Brush = value; OnPropertyChanged(); } }

        /* ------------------------------------------------------------------------------------------ */

        public PlotPoint() : this(0, 0) { }

        public PlotPoint(float x, float y, float Radius = 1, Pen pen = null, Brush brush = null)
            : this(new PointF(x, y), Radius, pen, brush) { }

        public PlotPoint(PointF point, float Radius, Pen pen = null, Brush brush = null)
            : this(Radius, pen, brush) { Position = point; }

        public PlotPoint(float Radius, Pen pen = null, Brush brush = null)
        {
            f_Pen = pen;
            f_R = Radius;
            f_Brush = brush;
        }

        /* ------------------------------------------------------------------------------------------ */

        #region Overrides of PrintableItem

        /// <summary>Метод отрисовки</summary>
        /// <param name="g">Графический контент</param>
        protected override void Draw(Graphics g)
        {
            var r = f_R;
            var r2 = r / 2;

            if(f_Pen != null)
                g.DrawArc(f_Pen, -r2, -r2, r, r, 0, 360);

            if(f_Brush != null)
                g.FillPie(f_Brush, -r2, -r2, r, r, 0, 360);
        }

        #endregion

        /* ------------------------------------------------------------------------------------------ */
    }
}
